package net.oschina.app.requests;

import java.util.HashMap;
import java.util.Map;

import net.oschina.app.common.PagingInfo;

import com.android.volley.AuthFailureError;
import com.android.volley.Response.ErrorListener;
import com.android.volley.Response.Listener;
import com.android.volley.toolbox.StringRequest;

public class PagingRequest extends StringRequest {
	private PagingInfo pi;

	public PagingRequest(String url,PagingInfo pagingInfo, Listener<String> listener,
			ErrorListener errorListener) {
		super(url, listener, errorListener);
		pi = pagingInfo;
	}
	
	@Override
	protected Map<String, String> getParams() throws AuthFailureError {
		Map<String, String> params = new HashMap<String, String>();
		params.put("pageIndex", pi.pageIndex+"");
		params.put("pageSize", pi.pageSize+"");
		if(pi.catalog != PagingInfo.INVALID_CATALOG){
			params.put("catalog", pi.catalog+"");
		}
		return params;
	}

}
